﻿@using CatalogModel

@model Manager.Models.MaterialClassViewModel

@{
	ViewBag.Title = "Delete";
	Layout = "~/Views/Shared/_Layout.cshtml";
	var type = Model.Item.GetType();
	var itemID = type.GetProperty("ID").GetValue(Model.Item);
}

<h2>Delete</h2>

<h3>Are you sure you want to delete this?</h3>
<div>
    <h4>@Model.TypeName</h4>
    <hr />

		@foreach (var prop in type.GetProperties())
		{
			<div class="row">
			@{
				var val = type.GetProperty(prop.Name).GetValue(Model.Item);

				if (val is ICodelist)
				{
					var value = (ICodelist)val;
						<div class="form-group">
							@Html.Label(prop.Name, htmlAttributes: new { @class = "control-label col-md-3" })
							<div class="col-md-9">
								<p>@value.ShortDescription</p>
							</div>
						</div>
				}
				else if (prop.PropertyType.Namespace.Contains("System"))
				{
						<div class="form-group">
							@Html.Label(prop.Name, htmlAttributes: new { @class = "control-label col-md-3" })
							<div class="col-md-9">
								<p>@val</p>
							</div>
						</div>
				}
			}
			</div>
	}


    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()

        <div class="form-actions no-color">
			@Html.Hidden("typeName", Model.TypeName)
            <input type="submit" value="Delete" class="btn btn-default" /> |
            @Html.ActionLink("Back to List", "Index", new { n = Model.TypeName })
        </div>
    }
</div>
